GskRoundedRect: Inline graphene_rect_contains_rect
authorTimm Bäder <mail@baedert.org>
Fri, 31 Jan 2020 16:08:17 +0000 (17:08 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 7 Feb 2020 18:16:32 +0000 (13:16 -0500)
Brings gsk_rounded_rect_contains_rect down from 0.54% to 0.14% when
rendering rounded backgrounds.

gsk/gskroundedrect.c

index 9a389b2eb7a7f5ccff6556957cc275ccc399b0d4..bde6078b4e45f14059d6313ea984a844bbf99532 100644 (file)
@@ -338,7 +338,10 @@ gboolean
 gsk_rounded_rect_contains_point (const GskRoundedRect   *self,
                                  const graphene_point_t *point)
 {
-  if (!graphene_rect_contains_point (&self->bounds, point))
+  if (point->x < self->bounds.origin.x ||
+      point->y < self->bounds.origin.y ||
+      point->x >= self->bounds.origin.x + self->bounds.size.width ||
+      point->y >= self->bounds.origin.y + self->bounds.size.height)
     return FALSE;
 
   if (self->bounds.origin.x + self->corner[GSK_CORNER_TOP_LEFT].width > point->x &&
@@ -395,7 +398,10 @@ gboolean
 gsk_rounded_rect_contains_rect (const GskRoundedRect  *self,
                                 const graphene_rect_t *rect)
 {
-  if (!graphene_rect_contains_rect (&self->bounds, rect))
+  if (rect->origin.x < self->bounds.origin.x ||
+      rect->origin.y < self->bounds.origin.y ||
+      rect->origin.x + rect->size.width >= self->bounds.origin.x + self->bounds.size.width ||
+      rect->origin.y + rect->size.height >= self->bounds.origin.y + self->bounds.size.height)
     return FALSE;
 
   if (!gsk_rounded_rect_contains_point (self, &rect->origin) ||